<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@include file="/WEB-INF/jsp/hadmin/addHeader.jsp"%>
<script type="text/javascript">
	var formUrl = "update.act?ajax=1";
	var validateConfig = {
		rules : {
			password : {
				minlength : 6
			},
			phoneNumber : {
				minlength : 11,
				maxlength : 11
			},
			confirm_password : {
				minlength : 6,
				equalTo : "[name='password']"
			}
		},
		messages : {
			password : {
				required : "请输入您的密码",
				minlength : "密码必须6个字符以上"
			},
			phoneNumber : {
				minlength : "请输入正确的手机号码",
				maxlength : "请输入正确的手机号码"
			},
			confirm_password : {
				required : "请再次输入密码",
				minlength : "密码必须6个字符以上",
				equalTo : "两次输入的密码不一致"
			},
			email : "请输入正确的E-mail地址"
		}
	};
	
	function onSubmit2(form) {
		if($(form).valid()){
			var temp = $("#password").val();
			if(temp && temp != ""){
				$("#password").val($.md5(temp));
			}
			$(form).ajaxSubmit({
				"url":getCurrentUrl(formUrl),
				"dataType":"json",
				"toastMsg":true,
				onSuccess:function(message){
					//parent.layer.msg(message.message);
					parent.iframes['${actionID}'].$("#${actionID}Table").bootstrapTable("refresh")
					//parent.iframes['${actionID}'].refresh();
					parent.layer.close(parent.layer.getFrameIndex(window.name)); //再执行关闭   
				}
			});
			$("#password").val(temp);
		}
		return false;
	}
</script>

<script src="${ctx}/js/jQuery.md5.js" type="text/javascript"></script>
<link href="${ctx }/h/css/plugins/iCheck/custom.css" rel="stylesheet">
</head>
<body class="gray-bg">
	<div class="row wrapper border-bottom white-bg page-heading">
		<div class="col-sm-10">
			<form method="post" onsubmit="return onSubmit2(this);"
				class="form-horizontal m-t" id="${actionID }Form">
				<div class="form-group">
					<label class="col-sm-3 control-label">ID：</label>
					<div class="col-sm-8">
						<input required name="nickName" class="form-control" type="text">
						<span class="help-block m-b-none"><i
							class="fa fa-info-circle"></i> 用户ID,不能更改</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">姓名：</label>
					<div class="col-sm-8">
						<input maxlength="10" name="name" class="form-control" type="text"
							class="valid">
					</div>
				</div>

				<div class="form-group">
					<label class="col-sm-3 control-label">密码：</label>
					<div class="col-sm-8">
						<input id="password" placeholder="不改留空" name="password" class="form-control"
							type="text">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">性别：</label>
					<div class="col-sm-8">
						<label class="checkbox-inline"> <input name="sex"
							type="radio" value="男">&nbsp;男
						</label> <label class="checkbox-inline"> <input name="sex"
							type="radio" value="女">&nbsp;女
						</label> <label class="checkbox-inline"> <input name="sex"
							type="radio" value="保密">&nbsp;保密
						</label>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">E-mail：</label>
					<div class="col-sm-8">
						<input name="email" class="form-control" type="email">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">联系号码：</label>
					<div class="col-sm-8">
						<input maxlength="11" required name="phoneNumber" class="form-control" type="number" data-noStar="true">
						<span style="position: absolute;right: 0;top: 0px;line-height: 45px;color: #ff0000;">*</span>
						<span class="help-block m-b-none"><i
							class="fa fa-info-circle"></i> 创建后用户需要通过手机验证码更改,用来找回密码</span>

					</div>
				</div>
				<div class="form-group" onselectstart="return false">
					<label class="col-sm-3 control-label">用户角色：</label>
					<div class="col-sm-8">
						<c:forEach items="${roleNameList }" var="temp" varStatus="status">
							<label class="checkbox-inline i-checks"> <input
							type="checkbox" <c:if test="${domain.roleSet.contains(temp) }">checked="checked"</c:if> name="roleSet" value="${temp.id }">${temp.name }
						</label>
						</c:forEach>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-8 col-sm-offset-3">
						<button class="btn btn-primary" type="submit">提交</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	<%@include file="/WEB-INF/jsp/hadmin/include/validateForm.jsp"%>
	<st:FillInputByDomain fieldsSkip="password,roleSet" />
</body>
<script src="${ctx }/h/js/plugins/iCheck/icheck.min.js"></script>
	<script>
        $(document).ready(function () {
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });
        });
    </script>
</html>
